<?php
/*
 * 剧情数据
 * @author:swyan
 * @date:2015-8-26
 */
set_time_limit(0);
function writeClientFile($target_file, $xml_data, $mode='wb'){
    $oldMask  = umask(0);
    $fp       = @fopen(CLIENT_CONFIG_DIR."/kingdombug/src/core/xx/PlotXX.ts", $mode);
	$content = "class PlotXX {";
	$content .="public static plotArr: PlotData[] = [";
    $i=0;
    $len=get_count($xml_data[$i],"plot_type");
	for($j=2;$j<count($xml_data[$i]);$j++){
		if ($xml_data[$i][$j]['plot_type'] != "") {
		$content .= "new PlotData(";
		$content .= $xml_data[$i][$j]['plot_type'].",";
		$content .= $xml_data[$i][$j]['index'].",";
		$content .= $xml_data[$i][$j]['trigger'].",";
		$content .= $xml_data[$i][$j]['key'].",";
		$content .= $xml_data[$i][$j]['role_type'].",";
		$content .= $xml_data[$i][$j]['pos'].",";
		$content .= "\"".$xml_data[$i][$j]['desc']."\"";
		$content .=")";
		if($j<(count($xml_data[$i])-1))
		$content .=",";
		}
    }
	$content .="];";
	$content .="}";
	
    fwrite($fp,$content);
    fclose($fp);
    umask($oldMask);
}
?>